package com.sunc.demo.order.feign;

import com.sunc.demo.item.entity.Item;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;
import java.util.Map;

@FeignClient(value = "springcloud-demo-item") //申明 Feign客户端，并指定ID
public interface ItemFeignClient {

    //这里有2中注解方式
    //第一种为feign内部注解，需要一定的学习成本
    //第二种为SpringMVC注解，也可以进行RESTful调用
    @RequestMapping(value = "/item/{id}",method = RequestMethod.GET)
    Item queryByItemId(@PathVariable("id") Long id);


    /**
     * 多参数方式一
     * @param name
     * @param price
     * @return
     */
    @RequestMapping(value = "/list",method = RequestMethod.GET)
    List<Item> list(@RequestParam("name") String name,@RequestParam("price") String price);

    /**
     * 多参数方式二
     * @param map
     * @return
     */
    @RequestMapping(value = "/list",method = RequestMethod.GET)
    List<Item> list2(@RequestParam Map<String,Object> map);



}
